using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations.Schema;

namespace Pay.Data {
	public class RoleFeatureMap : EntityTypeConfiguration<RoleFeature> {
		public RoleFeatureMap() {
			// table
			ToTable("mc_RoleFeature");

			// keys
			HasKey(t => t.Id);

			// Properties
			Property(t => t.Id)
				.HasColumnName("Id")
				.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
				.IsRequired();
			Property(t => t.FeatureId)
				.HasColumnName("FeatureId")
				.IsRequired();
			Property(t => t.RoleId)
				.HasColumnName("RoleId")
				.IsRequired();

			// Relationships
			HasRequired(t => t.Role)
				.WithMany(t => t.RoleFeatures)
				.HasForeignKey(d => d.RoleId)
				.WillCascadeOnDelete(false);
			HasRequired(t => t.Feature)
				.WithMany()
				.HasForeignKey(d => d.FeatureId)
				.WillCascadeOnDelete(false);
		}
	}
}
